package concurrency;

import java.util.concurrent.locks.LockSupport;

public class TestPark {
    public static void main(String[] args) {
        TestPark park = new TestPark();
        park.testPark();
    }

    private void testPark() {
        /**
         * jps 获取 pid
         * jstack pid
         * LockSupport.park(this)提供更多的堆栈阻塞信息
         */
        /**
         * "main" #1 prio=5 os_prio=0 cpu=359.38ms elapsed=19.83s tid=0x000002e9bcc6b800 nid=0x3438 waiting on condition  [0x000000ee21dfe000]
         *    java.lang.Thread.State: WAITING (parking)
         *         at jdk.internal.misc.Unsafe.park(java.base@12.0.1/Native Method)
         *         at java.util.concurrent.locks.LockSupport.park(java.base@12.0.1/LockSupport.java:324)
         *         at concurrency.TestPark.testPark(TestPark.java:12)
         *         at concurrency.TestPark.main(TestPark.java:8)
         */
//        LockSupport.park();
        /**
         *
         * "main" #1 prio=5 os_prio=0 cpu=312.50ms elapsed=14.39s tid=0x000001623fe9b800 nid=0x3fec waiting on condition  [0x000000444ccff000]
         *    java.lang.Thread.State: WAITING (parking)
         *         at jdk.internal.misc.Unsafe.park(java.base@12.0.1/Native Method)
         *         - parking to wait for  <0x00000007107f12a8> (a concurrency.TestPark)
         *         at java.util.concurrent.locks.LockSupport.park(java.base@12.0.1/LockSupport.java:194)
         *         at concurrency.TestPark.testPark(TestPark.java:25)
         *         at concurrency.TestPark.main(TestPark.java:8)
         */
        LockSupport.park(this);
    }
}
